home *** CD-ROM | disk | FTP | other *** search
-
- Listing 2
-
- #include <ctype.h>
-
- typedef int bool;
- #define FALSE 0
- #define TRUE 1
-
- int atoi(const char *s)
- {
- int n = 0;
- bool neg = FALSE;
-
- while (isspace(*s))
- ++s;
- if (*s == '+')
- ++s;
- else if (*s == '-')
- {
- neg = TRUE;
- ++s;
- }
- while (isdigit(*s))
- {
- n = 10 * n + *s - '0';
- ++s;
- }
- if (neg)
- n = -n;
- return n;
- }
-
- ----------
-
-